package o;

import android.os.Handler;
import android.os.Looper;
import android.view.View;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

public class dyf {
    private static final Object ˋ = new Object();
    private static Map<String, AtomicInteger> ˎ = new HashMap();
    private static volatile boolean ॱ = false;

    static class b implements IServerCallBack {
        List<ExposureDetail> ˎ;

        public b(List<ExposureDetail> list) {
            this.ˎ = list;
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            if (o_cvu instanceof dyb) {
                dyb o_dyb = (dyb) o_cvu;
                if (responseBean.getRtnCode_() != 0 || responseBean.getResponseCode() != 0) {
                    dyg.ॱ().ˎ(this.ˎ, o_dyb.getServiceType_());
                }
            }
        }
    }

    class c implements dmi {
        private boolean ˊ;
        private dyg ˎ;
        final /* synthetic */ dyf ˏ;
        private int ॱ;

        c(dyf o_dyf, dyg o_dyg, int i, boolean z) {
            this.ˏ = o_dyf;
            this.ˎ = o_dyg;
            this.ॱ = i;
            this.ˊ = z;
        }

        public void run() {
            this.ˏ.ˎ(this.ˎ, this.ॱ, this.ˊ);
        }
    }

    public static void ˎ(boolean z) {
        ॱ = z;
    }

    public boolean ˎ(View view) {
        if (view != null && ((double) evt.ˊ(view)) >= 50.0d) {
            return true;
        }
        return false;
    }

    public void ˊ(int i) {
        ˎ(i, true);
    }

    public void ˎ(int i, boolean z) {
        ˎ(dyg.ॱ(), i, z);
    }

    public void ˊ(dyg o_dyg, int i) {
        ॱ(o_dyg, i, true);
    }

    public void ॱ(final dyg o_dyg, final int i, final boolean z) {
        if (o_dyg.ˋ(i)) {
            ˎ(o_dyg, i, z);
        } else if (o_dyg.ˏ(i) > 0) {
            Looper mainLooper = Looper.getMainLooper();
            if (mainLooper != null) {
                new Handler(mainLooper).postDelayed(new Runnable(this) {
                    final /* synthetic */ dyf ॱ;

                    public void run() {
                        dmq.ˏ.ˊ(dmp.CONCURRENT, new c(this.ॱ, o_dyg, i, z));
                    }
                }, 10000);
            }
        }
    }

    public static boolean ˏ(String str) {
        boolean z;
        if (dof.ॱ(str)) {
            str = "default";
        }
        synchronized (ˋ) {
            AtomicInteger atomicInteger = (AtomicInteger) ˎ.get(str);
            if (atomicInteger == null) {
                atomicInteger = new AtomicInteger();
                ˎ.put(str, atomicInteger);
            }
            z = atomicInteger.get() == 0;
            if (str.equals("default")) {
                z = z && ॱ;
            }
        }
        return z;
    }

    private void ˋ(List<ExposureDetail> list) {
        if (CollectCheck.isEmpty((List) list)) {
            Logger.ˎ("ExposureController", "client.uploadExposurecalculateExposureTimes skipped, empty detailList.");
            return;
        }
        synchronized (ˋ) {
            Set<AtomicInteger> hashSet = new HashSet();
            for (ExposureDetail ˎ : list) {
                String ˎ2 = ˎ.ˎ();
                if (!dof.ॱ(ˎ2)) {
                    Object obj = (AtomicInteger) ˎ.get(ˎ2);
                    if (obj == null) {
                        obj = new AtomicInteger();
                        ˎ.put(ˎ2, obj);
                    }
                    hashSet.add(obj);
                }
            }
            for (AtomicInteger incrementAndGet : hashSet) {
                incrementAndGet.incrementAndGet();
            }
        }
    }

    private void ˎ(dyg o_dyg, int i, boolean z) {
        List ˎ = o_dyg.ˎ(i);
        ˋ(ˎ);
        String ˊ = o_dyg.ˊ(ˎ, i);
        if (dof.ॱ(ˊ)) {
            Logger.ˎ("ExposureController", "client.uploadExposure ignored, getExposureJson is empty.");
            return;
        }
        cvt o_dyb = new dyb();
        o_dyb.ˋ(ˊ);
        o_dyb.setServiceType_(i);
        o_dyb.setBlockIfProtocolNotAgreed(z);
        IServerCallBack bVar = new b(ˎ);
        if (Logger.ˎ()) {
            Logger.ˏ("ExposureController", "client.uploadExposure report times:" + ˎ);
        }
        cfw.ˎ(o_dyb, bVar);
    }
}
